home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 March / macformat-022.iso / Shareware City / Developers / src / out-of-phase-102-c / OutOfPhase 1.02 Source / OutOfPhase Folder / ASTExpression.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-23  |  5.3 KB  |  151 lines  |  [TEXT/KAHL]

  1. /* ASTExpression.h */
  2.  
  3. #ifndef Included_ASTExpression_h
  4. #define Included_ASTExpression_h
  5.  
  6. /* ASTExpression module depends on */
  7. /* MiscInfo.h */
  8. /* Audit */
  9. /* Debug */
  10. /* Definitions */
  11. /* TrashTracker */
  12. /* Memory */
  13. /* PcodeObject */
  14. /* CompilerRoot */
  15. /* ASTArrayDeclaration */
  16. /* ASTAssignment */
  17. /* ASTBinaryOperator */
  18. /* ASTConditional */
  19. /* ASTExpressionList */
  20. /* ASTFuncCall */
  21. /* ASTLoop */
  22. /* ASTOperand */
  23. /* ASTUnaryOperator */
  24. /* ASTVariableDeclaration */
  25. /* SymbolTableEntry */
  26.  
  27. #include "PcodeObject.h"
  28. #include "CompilerRoot.h"
  29.  
  30. struct ASTExpressionRec;
  31. typedef struct ASTExpressionRec ASTExpressionRec;
  32.  
  33. /* all memory allocated in this module is through TrashTracker */
  34.  
  35. typedef enum
  36.     {
  37.         eExprArrayDeclaration EXECUTE(= -9769),
  38.         eExprAssignment,
  39.         eExprBinaryOperator,
  40.         eExprConditional,
  41.         eExprExpressionList,
  42.         eExprFunctionCall,
  43.         eExprLoop,
  44.         eExprOperand,
  45.         eExprUnaryOperator,
  46.         eExprVariableDeclaration,
  47.         eExprErrorForm,
  48.         eExprWaveGetter
  49.     } ExprTypes;
  50.  
  51. /* forwards */
  52. struct TrashTrackRec;
  53. struct ASTArrayDeclRec;
  54. struct ASTAssignRec;
  55. struct ASTBinaryOpRec;
  56. struct ASTCondRec;
  57. struct ASTExprListRec;
  58. struct ASTFuncCallRec;
  59. struct ASTLoopRec;
  60. struct ASTOperandRec;
  61. struct ASTUnaryOpRec;
  62. struct ASTVarDeclRec;
  63. struct ASTErrorFormRec;
  64. struct ASTWaveGetterRec;
  65. struct SymbolRec;
  66.  
  67. /* construct a generic expression around an array declaration */
  68. ASTExpressionRec*        NewExprArrayDecl(struct ASTArrayDeclRec* TheArrayDeclaration,
  69.                                             struct TrashTrackRec* TrashTracker, long TheLineNumber);
  70.  
  71. /* construct a generic expression around an assignment statement */
  72. ASTExpressionRec*        NewExprAssignment(struct ASTAssignRec* TheAssignment,
  73.                                             struct TrashTrackRec* TrashTracker, long TheLineNumber);
  74.  
  75. /* construct a generic expression around a binary operator */
  76. ASTExpressionRec*        NewExprBinaryOperator(struct ASTBinaryOpRec* TheBinaryOperator,
  77.                                             struct TrashTrackRec* TrashTracker, long TheLineNumber);
  78.  
  79. /* construct a generic expression around a conditional. */
  80. ASTExpressionRec*        NewExprConditional(struct ASTCondRec* TheConditional,
  81.                                             struct TrashTrackRec* TrashTracker, long TheLineNumber);
  82.  
  83. /* construct a generic expression around a list of expressions. */
  84. ASTExpressionRec*        NewExprSequence(struct ASTExprListRec* TheExpressionList,
  85.                                             struct TrashTrackRec* TrashTracker, long TheLineNumber);
  86.  
  87. /* construct a generic expression around a function call */
  88. ASTExpressionRec*        NewExprFunctionCall(struct ASTFuncCallRec* TheFunctionCall,
  89.                                             struct TrashTrackRec* TrashTracker, long TheLineNumber);
  90.  
  91. /* construct a generic expression around a loop */
  92. ASTExpressionRec*        NewExprLoop(struct ASTLoopRec* TheLoop,
  93.                                             struct TrashTrackRec* TrashTracker, long TheLineNumber);
  94.  
  95. /* construct a generic expression around an operand */
  96. ASTExpressionRec*        NewExprOperand(struct ASTOperandRec* TheOperand,
  97.                                             struct TrashTrackRec* TrashTracker, long TheLineNumber);
  98.  
  99. /* construct a generic expression around a unary operator */
  100. ASTExpressionRec*        NewExprUnaryOperator(struct ASTUnaryOpRec* TheUnaryOperator,
  101.                                             struct TrashTrackRec* TrashTracker, long TheLineNumber);
  102.  
  103. /* construct a generic expression around a variable declaration */
  104. ASTExpressionRec*        NewExprVariableDeclaration(struct ASTVarDeclRec* TheVariableDecl,
  105.                                             struct TrashTrackRec* TrashTracker, long TheLineNumber);
  106.  
  107. /* construct a generic expression around an error form */
  108. ASTExpressionRec*        NewExprErrorForm(struct ASTErrorFormRec* TheErrorForm,
  109.                                             struct TrashTrackRec* TrashTracker, long TheLineNumber);
  110.  
  111. /* construct a generic expression around a wave getter */
  112. ASTExpressionRec*        NewExprWaveGetter(struct ASTWaveGetterRec* TheWaveGetter,
  113.                                             struct TrashTrackRec* TrashTracker, long TheLineNumber);
  114.  
  115.  
  116. /* type check an expression.  returns eCompileNoError and the resulting value */
  117. /* type if it checks correctly. */
  118. CompileErrors                TypeCheckExpression(DataTypes* ResultTypeOut,
  119.                                             ASTExpressionRec* TheExpression, long* ErrorLineNumber,
  120.                                             struct TrashTrackRec* TrashTracker);
  121.  
  122. /* get a symbol table entry out of an expression.  this is used for getting */
  123. /* function generation stuff. */
  124. CompileErrors                ExpressionGetFunctionCallSymbol(struct SymbolRec** SymbolOut,
  125.                                             ASTExpressionRec* TheExpression);
  126.  
  127. /* find out if the expression is a valid lvalue */
  128. MyBoolean                        IsExpressionValidLValue(ASTExpressionRec* TheExpression);
  129.  
  130. /* find out what kind of expression it is */
  131. ExprTypes                        WhatKindOfExpressionIsThis(ASTExpressionRec* TheExpression);
  132.  
  133. /* generate code for any expression.  returns True if successful, or False if it fails. */
  134. MyBoolean                        CodeGenExpression(struct PcodeRec* FuncCode, long* StackDepthParam,
  135.                                             ASTExpressionRec* Expression);
  136.  
  137. /* get the operand from the generic expression */
  138. struct ASTOperandRec*    GetOperandOutOfExpression(ASTExpressionRec* TheExpression);
  139.  
  140. /* get the binary operator out of the generic expression */
  141. struct ASTBinaryOpRec*    GetBinaryOperatorOutOfExpression(ASTExpressionRec* TheExpression);
  142.  
  143. /* get the type of value that is returned by this expression */
  144. DataTypes                        GetExpressionsResultantType(ASTExpressionRec* TheExpression);
  145.  
  146. /* generate code for an expression.  returns True if successful, or False if it fails. */
  147. MyBoolean                        CodeGenExpression(struct PcodeRec* FuncCode,
  148.                                             long* StackDepthParam, ASTExpressionRec* Expression);
  149.  
  150. #endif
  151.